# -*- coding: utf-8 -*-
import win32com
from win32com.client import Dispatch, constants

w = win32com.client.Dispatch('Word.Application')

# # 后台运行，不显示，不警告
# w.Visible = 0
# w.DisplayAlerts = 0
#
# # 打开新的文件
# doc = w.Documents.Open( FileName = "testWord.doc" )
# # worddoc = w.Documents.Add() # 创建新的文档
#
# # 插入文字
# myRange = doc.Range(0,0)
# myRange.InsertBefore('Hello from Python!')
#
# # 打印
# doc.PrintOut()
#
# # 关闭
# # doc.Close()
# w.Documents.Close(wc.wdDoNotSaveChanges)
w.Quit()